<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>{:SEO('article-add','title')}</title>
<meta name="keywords" content="{:SEO('article-add','keywords')}">
<meta name="description" content="{:SEO('article-add','description')}">
<link href="__ROOT__/{:C('UU_TPL_DIR')}/public/css/article.css"     rel="stylesheet" type="text/css">
<include file="public:header" />

 


  <div class="article_add">
  
  <if condition="$Think.session.uu.uid eq ''">
  		<div class="logintip">
		  		<div class="txt font_yellow">&nbsp;&nbsp;&nbsp;&nbsp;已有账号？登陆后获取特权!</div>
		  <div class="txt">
				<div class="btn_green btn_inline_small btn_border J_user_login">立刻登录</div>
		  </div>
			  <div class="txt font_gray6">用第三方账号登录</div>
			  <div class="txt">
		  			<volist name="oauth_list" id="oauth">
			<a class="uu_api_login_btn {$key}" href="{:U('callback/index',array('mod'=>$key,'type'=>'login'))}"></a>
		</volist>
					<div class="clear"></div>
			  </div>
		  <div class="clear"></div>
		</div>
	</if>
	
	<form  name="add"  method="post" action="{:RU('article/addsave')}">
		
		<h4>文章标题</h4>
		
    <div class="inputbox zindextop">
		<input name="title" type="text" class="inputs w560"  placeholder="请在这里输入文章标题">
		
		<if condition="C('UU_CAT_LEVEL_ARTICLE') gt '0'">
		
	  <div class="categorysel J_cat_menu">选择文章分类</div>
		<input name="category1" id="J_category1" type="hidden" value="0">
		<input name="category2" id="J_category2" type="hidden" value="0">
		<div class="show_menu J_cat_show_menu">
			<ul>
				<uu:cat listname="li" type="2" pid="0"/>
				<volist name="li.list" id="li">
				<li id="{$li.c_id}" title="{$li.c_title}"><span class="liimg"><img src="__ROOT__/{:C('UU_IMG_CATEGORY_DIR')}{$li.c_pic}" /></span>{$li.c_title}</li>
				</volist>
			</ul>
		</div>
		
		</if>
		
	  </div>
		
		<h4>文章正文</h4>
	<div class="inputbox">
		<textarea name="content"  id="contentqq" cols="" rows="" class="inputs h100" placeholder="请在这里输入文章正文"></textarea>
	</div>
	
		 <div class="tagdiv"> 
				   <div class="tagbox">
				     <div class="addtag" id="J_addtag">选择标签</div>
   					     <div class="tip">添加多个标签能使文章快速传播</div>
	               </div>
      </div>
	
	<div class="upimg">
	  	<div class="addimgbtn" id="J_upload_btn" name="article_img" >上传封面图片<span>(建议尺寸245*180)</span></div>
	</div>
	  
	  
	<!--最多可选择3个标签 ,未添加下方DIV默认 display:none -->
     <div class="showtag">
				<div class="tip">你还可以添加<span>3</span>个标签</div>
				<div class="clear"></div>
    </div>
 

<if condition="$Think.session.uu.uid eq ''"> 

     <div class="mb">
	   <div class="mbmain"> 
	     <input type="text" class="mbiput" maxlength="11" onKeyUp="if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,'');"onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"  placeholder="输入手机号"  name="mobile" >
	     
	     <input type="text" class="mbiput code" maxlength="11" onKeyUp="if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,'');"onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))" placeholder="输入验证码"  name="code">
		 <div class="mbiput btn" id="J_send_code">获取验证码</div>
        </div>
	 </div>
	 
</if> 
	 
     <div class="btns">

	   <input name="" type="button" id="J_add" value="保存文章" class="btn"> 

	 
	   
	   <div class="clear"></div>
    </div>
    </form>
	 
  </div>
  
  
  
 
<include file="public:footer" />
<script charset="utf-8" src="__ROOT__/{:C('UU_TPL_DIR')}/public/js/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="__ROOT__/{:C('UU_TPL_DIR')}/public/js/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript">
KindEditor.ready(function(K) {
				K.each({
					'plug-align' : {
						name : '对齐方式',
						method : {
							'justifyleft' : '左对齐',
							'justifycenter' : '居中对齐',
							'justifyright' : '右对齐'
						}
					},
					'plug-order' : {
						name : '编号',
						method : {
							'insertorderedlist' : '数字编号',
							'insertunorderedlist' : '项目编号'
						}
					},
					'plug-indent' : {
						name : '缩进',
						method : {
							'indent' : '向右缩进',
							'outdent' : '向左缩进'
						}
					}
				},function( pluginName, pluginData ){
					var lang = {};
					lang[pluginName] = pluginData.name;
					KindEditor.lang( lang );
					KindEditor.plugin( pluginName, function(K) {
						var self = this;
						self.clickToolbar( pluginName, function() {
							var menu = self.createMenu({
									name : pluginName,
									width : pluginData.width || 100
								});
							K.each( pluginData.method, function( i, v ){
								menu.addItem({
									title : v,
									checked : false,
									iconClass : pluginName+'-'+i,
									click : function() {
										self.exec(i).hideMenu();
									}
								});
							})
						});
					});
				});
				K.create('#contentqq', {
				    uploadJson : "{:RU('upload/img',array('type'=>'kindeditor_img'))}",
					filePostName : 'kindeditor_img',
					themeType : 'qq',
					items : [
						'bold','italic','underline','fontname','fontsize','forecolor','hilitecolor','plug-align','plug-order','plug-indent','link'
					,'image'],
					afterBlur:function(){this.sync();} 
				});
			});
		</script>

<!--未登录发布问题 -->
<script type="text/javascript">
$(document).ready(function()
{
        //提交问题  
        $("#J_add").click(function(){
			$(this).val('正在提交......').attr("disabled","disabled");
            title=$('input[name=title]').val();
			content=$('textarea[name=content]').val();
			if (title==''){
				disapperTooltip("remind", "请填写文章标题");
				$(this).val('保存文章').removeAttr("disabled");
				 return false;
			}
			else if (title.length < 5) {
          		 disapperTooltip("remind", "您的文章标题太短了！");
				 $(this).val('保存文章').removeAttr("disabled");
           		 return false;
        	}
			if (content==''){
				disapperTooltip("remind", "请填写文章内容");
				$(this).val('保存文章').removeAttr("disabled");
			 return false;
			}
			<if condition="C('UU_CAT_LEVEL_ARTICLE') gt '0'">
			category1=$('input[name=category1]').val();
			if (category1=='0' || category1==''){
				disapperTooltip("remind", "请选择分类！");
				$(this).val('保存文章').removeAttr("disabled");
				 return false;
			}
			</if>
			<if condition="$Think.session.uu.uid eq ''">
			code=$('input[name=code]').val();
			if (code==''){
				disapperTooltip("remind", "请填写短信验证码！");
				$(this).val('保存文章').removeAttr("disabled");
				 return false;
			}else{
					$.getJSON(ajaxURL, { act: "ajax_mobile_code_verify",code:code}, function(json){
						if (json.status==0){
							disapperTooltip("remind",json.content);
							$("#J_add").val('保存文章').removeAttr("disabled");
							return false;
						}else if (json.status==1){
							$("form[name=add]").submit();
						}else{
							disapperTooltip("remind","未知错误");
							$("#J_add").val('保存文章').removeAttr("disabled");
							return false;
						}
					});
			}
			<else />
			$("form[name=add]").submit();
			</if>
			
        });
		//发送验证码
		$("#J_send_code").click(function(){
					btn=$(this);
					if (btn.hasClass('btn_disabled')) return false;
					function settime(countdown) {
						if (countdown == 0) {
							$('#J_send_code').removeClass('btn_disabled');
							$('#J_send_code').text('获取验证码');
							countdown = {:C('UU_SMS_SETTIME')};
							return;
						} else {
							$('#J_send_code').addClass('btn_disabled');
							$('#J_send_code').text('重新发送' + countdown + '秒');
							countdown--;
						}
						setTimeout(function() {
							settime(countdown)
						},1000)
					}
					var mobile=$('input[name=mobile]').val();
					if (mobile.length!=11){
						disapperTooltip("remind",'请填写正确的手机号');
						return false;
					}
					btn.addClass('btn_disabled').html('正在发送中.');
					$.getJSON(ajaxURL, { act:"ajax_send_mobile_code",mobile:mobile,in_user:0}, function(json){
						if (json.status==0){
							btn.removeClass('btn_disabled').html('获取验证码');
							disapperTooltip("remind",json.content);
						}else if (json.status==1){
							disapperTooltip("success",json.content);
							settime({:C('UU_SMS_SETTIME')});
						}else{
							btn.removeClass('btn_disabled').html('获取验证码');
							disapperTooltip("remind",json.content);
						}
					});
		});
});
</script>
<script type="text/javascript">
	var uploadUrl = "{:RU('Upload/img')}";
</script>
<script src="__ROOT__/{:C('UU_TPL_DIR')}/public/js/ajaxfileupload.js"></script>
<script src="__ROOT__/{:C('UU_TPL_DIR')}/public/js/fileupload.js"></script>
<script src="__ROOT__/data/cache_cat.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
// 上传图标
$.upload('#J_upload_btn',{type:'article_img'},function(result){
		if(result.status == 1){;
			html=htmlSTR(); 
			$(".upimg").prepend(html).show();
			var imgobj=".input_up_img ";
			$(imgobj).find('a').attr('href',result.content.src);
			$(imgobj).find('img').attr('src',result.content.src);
			$(imgobj).find('input').val(result.content.savename);
			$('.addimgbtn').hide();
		} else {
			disapperTooltip("remind", "上传失败："+result.content);
		}
		//生成html
		function htmlSTR(){
			html="";  
			html+="<div class=\"input_up_img\">";
			html+="<a href=\"#\" target=\"_blank\"><input name=\"img\" type=\"hidden\" value=\"#\"><img src=\"#\" border=\"0\" /></a>";
			html+="<div class=\"del J_img_del\">删除</div>";
			html+="</div>";
			return html;
		}
		
	});
	//删除上传图片
	$('.J_img_del').live('click',function() {
	 	$(this).parent(".input_up_img").remove();
		$(".addimgbtn").show();
	});
	//一二级分类切换
	<if condition="C('UU_CAT_LEVEL_ARTICLE') eq '1'">
	ShowMenu('.J_cat_menu','#J_category1','.J_cat_menu','.J_cat_show_menu');
	<else />
	
	//二级分类
	$('.J_cat_menu').live('click',function() {
		 var UUDialog = $(this).dialog({
		        title: false,
        		loading: true,
				footer: false,
				header: false,
				border: false,
				backdrop: false
		});
		 $.getJSON(ajaxURL, { act: "ajax_cat_list",type:2}, function(json){
					if (json.status==0){
						UUDialog.hide();
						disapperTooltip("remind", json.content);
					}else if (json.status==1){
						UUDialog.hide();
						var MDialog = $(this).dialog({
								title: "请选择分类",
								content:json.content,
								footer: true,
								header: true,
								border: true,
								innerPadding: true,
								backdrop: true,
						 		yes: function() {
									cbtn=$(".ajax_cat_list span.select");
									ctit=cbtn.attr('title');
									category1=cbtn.attr('category1');
									category2=cbtn.attr('category2');
									if (ctit!='')
									{
										$('.J_cat_menu').text(ctit);
										$('#J_category1').val(category1);
										$('#J_category2').val(category2);
										$('.modal').remove();
										$('.modal_backdrop').remove();
									}
								 
							}
						});
						MDialog.setCloseDialog(false);
					}else{
						UUDialog.hide();
						disapperTooltip("remind","未知错误");
					}
		});
	});
	
	</if>
	

});
</script>
<script type="text/javascript">
$(document).ready(function()
{
//打开添加标签页JS操作 (ajax_tag_list.html页面操作)
TAGnum=3;//允许TAG添加数量

//打开标签弹窗
$('#J_addtag').live('click',function() {
		 var UUDialog = $(this).dialog({
		        title: false,
        		loading: true,
				footer: false,
				header: false,
				border: false,
				backdrop: false
		});
		
		tags=$(".showtag .tag");
		tags_str='';
		if (tags.length>0)
		{
			tags_arr=new Array();
			tags.each(function(i){
			tags_arr[i]=$(this).attr('title');
			});
			tags_str=tags_arr.join("__uuask__");
		}
		 $.getJSON(ajaxURL, { act: "ajax_tag_list",tags:tags_str}, function(json){
					if (json.status==0){
						UUDialog.hide();
						disapperTooltip("remind", json.content);
					}else if (json.status==1){
						UUDialog.hide();
						var MDialog = $(this).dialog({
								title: "请选择标签",
								content:json.content,
								footer: true,
								header: true,
								border: true,
								innerPadding: true,
								backdrop: true,
						 		yes: function() {
									tags=$(".ajax_tag_list .tagli.select");
									if (tags.length>0)
									{
										html='';
										tags.each(function(i){
										html+='<div class="tag" title="'+$(this).attr('title')+'">'+$(this).attr('title')+'<input name="tag[]" type="hidden" value="'+$(this).attr('title')+'"></div>';
										});
										$('.showtag .tag').remove();
										$('.showtag').prepend(html).show();
										unm=TAGnum-tags.length;
										$('.showtag .tip span').html(unm);
									}
								 
							}
						});
					}else{
						UUDialog.hide();
						disapperTooltip("remind","未知错误");
					}
		});
	});
//从窗口选择标签
$('.ajax_tag_list .tagli').live('click',function()
{
	if ($(this).hasClass('select')){
	$(this).removeClass('select');
	}else{
	$(this).addClass('select');
	}
	if ($(".ajax_tag_list .tagli.select").length>TAGnum){
	disapperTooltip("remind","最多只能选择"+TAGnum+"个标签");
	$(this).removeClass('select');
	}
});
//搜索标签
$('.J_sotag_btn').live('click',function()
{
	btn=$(this);
	btn.attr("disabled","disabled").addClass('btn_disabled');
	tagkey=$('#J_tagkey').val();
	if (tagkey.length==0)
	{
		disapperTooltip("remind","请填写关键字！");
		btn.removeAttr("disabled").removeClass('btn_disabled');
		return false;
	}
	$.getJSON(ajaxURL,{act: "ajax_tag_so",tagkey:tagkey}, function(json){
					
					if (json.status==0)
					{
						disapperTooltip("remind", json.content);
						btn.removeAttr("disabled").removeClass('btn_disabled');
					}
					else if (json.status==1)
					{
							if (json.count==0)
							{
								$('.ajax_tag_list .soshow').hide();
								$('.ajax_tag_list .soempty').show();
								$(".ajax_tag_list .soempty strong").html(json.key);
								$(".ajax_tag_list .soempty .J_add_tag_key").attr('title',json.key);
							}
							else
							{
								$('.ajax_tag_list .soshow').show();
								$('.ajax_tag_list .soempty').hide();
								tag=json.content;
								htm='';
								for(var i in tag)
								{
								htm+="<div class=\"tagli\" title=\""+tag[i].tag+"\">"+tag[i].tag+"</div>";
								}
								htm+="<div class=\"clear\"></div>";
								$(".ajax_tag_list .soshow .stxt").html(htm);
							}
							btn.removeAttr("disabled").removeClass('btn_disabled');
					}else{
						disapperTooltip("remind","未知错误");
						//
						btn.removeAttr("disabled").removeClass('btn_disabled');
						//
					}
	});

});
//从搜索结果添加标签
$('.J_add_tag_key').live('click',function()
{
	tag=$(this).attr('title');
	if ($(".ajax_tag_list .tagli[title='"+tag+"']").length>0)
	{
	disapperTooltip("remind",tag+"已存在，不能重复添加标签");
	return false;
	}
	else
	{
		if ($(".ajax_tag_list .tagli.select").length>=TAGnum){
		html="<div class=\"tagli\" title="+tag+">"+tag+"</div>";
		$(".ajax_tag_list .tlist .clear").before(html);
		}
		else
		{
		html="<div class=\"tagli select\" title="+tag+">"+tag+"</div>";
		$(".ajax_tag_list .tlist .clear").before(html);
		}		
	}
});
//删除所选标签
$('.showtag .tag').live('click',function()
{
	$(this).remove();
	tags=$('.showtag .tag');
	if (tags.length==0)
	{
	$('.showtag').hide();
	}
	unm=TAGnum-tags.length;
	$('.showtag .tip span').html(unm);
});
	
});
</script>
</body>
</html>
